/**
 * Created by Administrator on 2017/8/1.
 */

import { CACHE } from '../mutations-types';
// 首页tab
const defaultCache = {
  homeTab:0,
  tabCut:0,
  transfer:0
};
// 影院详情轮播
const defaultJump = {
  actionJumpIndex:0,
  actionJumpTrue:0
};
// 影片tab下拉数量
const defaultFilm = {
  paramsIndex:10,
  waitIndex:10
};
// 影院选择
const defaultCinema = {
  userSelection:0,
  region:0,
  areaIndex:0,
  rank:0,
  selectDefault:0
};
// 影院排序
const defaultRank = {
  userArea:0,
  userSort:0
};
// 活动信息
const defaultActivity = {
  codeEnabled:0,
  filmUrl:'',
  gonggao:'',
  huodong:'',
  isActivity:0,
  sanpin:'',
  tip:'',
  discAmt:'',
  newTipInfo:'',
  xuanfu:''
};
const CacheModule = {
  state: {
    cache: defaultCache,
    jump: defaultJump,
    film:defaultFilm,
    cinema:defaultCinema,
    rank:defaultRank,
    activity:defaultActivity
  },
  mutations: {
    [CACHE.UPDATE_CACHE](state, cache = defaultCache){
      if (!cache) {
        cache = defaultCache;
      }
      state.cache = {
        ...cache
      };
    },
    [CACHE.UPDATE_JUMP](state, jump = defaultJump){
      if (!jump) {
        jump = defaultJump;
      }
      state.jump = {
        ...jump
      };
    },
    [CACHE.UPDATE_FILM](state, film = defaultFilm){
      if (!film) {
        film = defaultFilm;
      }
      state.film = {
        ...film
      };
    },
    [CACHE.UPDATE_CINEMA](state, cinema = defaultCinema){
      if (!cinema) {
        cinema = defaultCinema;
      }
      state.cinema = {
        ...cinema
      };
    },
    [CACHE.UPDATE_RANK](state, rank = defaultRank){
      if (!rank) {
        rank = defaultRank;
      }
      state.rank = {
        ...rank
      };
    },
    [CACHE.UPDATE_ACTIVITY](state, activity = defaultActivity){
      if (!activity) {
        activity = defaultActivity;
      }
      state.activity = {
        ...activity
      };
    }
  }
};

export default CacheModule;

